home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.19950329-19950528
/
000357_news@columbia.edu_Wed May 10 20:53:55 1995.msg
< prev
next >
Wrap
Internet Message Format
|
1995-07-31
|
4KB
Received: from apakabar.cc.columbia.edu by watsun.cc.columbia.edu with SMTP id AA11155
(5.65c+CU/IDA-1.4.4/HLK for <kermit.misc@watsun.cc.columbia.edu>); Wed, 10 May 1995 16:54:18 -0400
Received: by apakabar.cc.columbia.edu id AA10093
(5.65c+CU/IDA-1.4.4/HLK for kermit.misc@watsun); Wed, 10 May 1995 16:54:14 -0400
Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: XIF for MS-DOS Kermit
Date: 10 May 1995 20:53:55 GMT
Organization: Columbia University
Lines: 107
Message-Id: <3or953$9q8@apakabar.cc.columbia.edu>
Nntp-Posting-Host: watsun.cc.columbia.edu
Apparently-To: kermit.misc@watsun.cc.columbia.edu
The MS-DOS Kermit script programming language has an IF command that looks
like this:
IF <condition> <command>
which executes the <command> if the <condition> is true.
The C-Kermit language has this too, but also has an "extended IF", or
XIF, command:
XIF <condition> { <commands> } [ ELSE { <other-commands> } ]
in which the <commands> are one or more commands separated (if more than
one) by commas, and there is an optional ELSE part to be executed if the
<condition> is not true. This is handy for grouping commands together to
be executed conditionally without resorting to lots of ugly GOTOs.
Here is a macro that you can use in MS-DOS Kermit to get the XIF effect.
It is *almost* totally compatible with C-Kermit's XIF command, but not
quite. The difference is that, when using this macro, you must enclose
the <condition> in curly braces, whereis in C-Kermit, you must *not*
enclose the <condition> in curly braces. Left as an exercise to the
reader: eliminate this incompatibility :-)
---(cut)---
define XIF -
_assign _then\v(cmdlevel) \%2,-
if def \%3 if not eq "\%3" "ELSE" end 1 "\%3" should be "ELSE",-
if def \%4 _assign _else\v(cmdlevel) \%4,-
if \%1 do _then\v(cmdlevel),-
if def \%4 if NOT \%1 do _else\v(cmdlevel)
---(cut)---
Aside from the { <condition> } business, you should be able to use this macro
exactly as you would use C-Kermit's XIF. Here is a script to give it a
workout:
---(cut)---
ec Testing XIF...
xif { = 1 1 } { echo THEN part works. }
xif { = 1 0 } { echo This should not appear } else { echo ELSE part works. }
echo Multiple commands in THEN part...
xif { = 1 1 } { echo Line 1 of 3 OK, ec Line 2 of 3 OK, ec Line 3 of 3 OK }
echo Same thing, with line continuation...
xif { = 1 1 } { -
echo Line 1 of 3 OK,-
echo Line 2 of 3 OK,-
echo Line 3 of 3 OK -
}
echo Multiple commands in THEN and ELSE parts, THEN part true...
xif { = 1 1 } { -
echo THEN 1 of 3 OK,-
echo THEN 2 of 3 OK,-
echo THEN 3 of 3 OK -
} else { -
echo ELSE 1 of 3 OK,-
echo ELSE 2 of 3 OK,-
echo ELSE 3 of 3 OK -
}
echo Multiple commands in THEN and ELSE parts, THEN part false...
xif { = 1 0 } { -
echo THEN 1 of 3 OK,-
echo THEN 2 of 3 OK,-
echo THEN 3 of 3 OK -
} else { -
echo ELSE 1 of 3 OK,-
echo ELSE 2 of 3 OK,-
echo ELSE 3 of 3 OK -
}
echo Testing nested XIFs...
xif { = 1 1 } { -
xif { = 2 0 } { -
echo This should NOT appear -
} else { -
echo This SHOULD appear -
} -
} else { -
echo This should NOT appear -
}
echo And again...
xif { = 1 0 } { -
echo This should NOT appear, -
xif { = 2 2 } { -
echo This should NOT appear -
} else { -
echo This should NOT appear -
} -
} else { -
echo This SHOULD appear, -
xif { = 2 2 } { -
echo This SHOULD appear -
} else { -
echo This should NOT appear -
} -
}
---(cut)---
- Frank